package net.gagnat.test.mediabatch.reader;

import net.gagnat.test.mediabatch.domain.Media;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.validation.BindException;

public class MediaFieldSetMapper implements FieldSetMapper<Media> {

    @Override
    public Media mapFieldSet(FieldSet fieldSet) throws BindException {
        Media media = new Media();
        int index = 0;
        media.setPersonId(fieldSet.readString(index++));
        media.setRecordType(fieldSet.readInt(index++));
        media.setFritekst(fieldSet.readString(index++));
        return media;
    }

}
